<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>菜单管理</title>
        <link rel="stylesheet" href="/static/lib/layui/css/layui.css" media="all">
    </head>
    <body>
        <div style="margin: 10px 10px 10px 10px;">
            <!--数据表格主体-->
            <table id="munu-parent-table" lay-filter="munu-parent-table"></table>
        </div>
        <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
        <script>
            var checkedbox=[];
            layui.extend({
                treeTable: '/static/js/lay-module/treetable-lay/treeTable' //table树形扩展
            }).use(['treeTable'], function () {
                var $ = layui.jquery;
                var treeTable = layui.treeTable;
                // 渲染树形表格
                var insTb = treeTable.render({
                    elem: '#munu-parent-table',
                    url: '/sys/menu/parent/list',
                    tree: {
                        iconIndex: 1,           // 折叠图标显示在第几列
                        isPidData: true,        // 是否是id、pid形式数据
                        idName: 'id',  // id字段名称
                        pidName: 'parentId',     // pid字段名称
                        getIcon: function (obj) {
                            return '';
                        }
                    },
                    cols: [
                        [
                            {type: 'radio'},
                            {field: 'title', width: '40%', title: '菜单名称'},
                            {field: 'authority', width: '30%', title: '权限标识', align: 'center'},
                            {field: 'description', width: '30%', title: '描述', align: 'center'}
                        ]
                    ],
                    skin: 'line'
                });

                treeTable.on('checkbox(munu-parent-table)', function(obj){
                    if(obj.checked){
                        checkedbox['id']=obj.data.id;
                        checkedbox['parentId']=obj.data.parentId;
                        checkedbox['title']=obj.data.title;
                    }
                });
            });
        </script>
    </body>
</html>